<?php

use yii\db\Schema;
use yii\db\Migration;

class m160122_072030_add_mobile_brand_taxonomy extends Migration
{
    public function up()
    {
        $sql = <<<FINE
create table if not exists {{%mobile_device_brand}} (
    `id` int(11) not null auto_increment,
    `name` varchar(32) not null comment '手机品牌',
    `description` varchar(200), 
    `status` int(1) NOT NULL DEFAULT '1' COMMENT '1 有效， 0 无效（删除或其他情况）',
    `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
)engine=innodb default charset=utf8;

insert into {{%mobile_device_brand}} (name) values ('iPhone'), ('htc'), ('xiaomi'), ('nubia'), ('huawei');
FINE;
        $this->execute($sql);

    }

    public function down()
    {
        return $this->dropTable('{{%mobile_device_brand}}');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
